// JavaScript Document

function enterPressed(evn) 
{
   if (window.event && window.event.keyCode == 13) 
  {
   chkUserName();
  }
   else if (evn && evn.keyCode == 13) 
   {
    chkUserName();
   }
}
document.onkeypress = enterPressed;

function chkUserName()
{
  //checking the Username
  var name = document.getElementById("name").value;
  if (name == "Kevin" || name == "kevin")
  {
    chkPassword();
  }
  else if (name == "Harrison" || name == "harrison")
  {
   chkPassword();
  }
  else if (name == "John" || name == "john")
  {
	chkPassword();
  }
  else if (name == "Mark" || name == "mark")
  {
	chkPassword();
  }	
  else
  {
    location.replace('authentication_Failure_Page.html'); //authentication failure page
  }
}

function chkPassword()
{
  //if I got here the userName is valid
  //checking the password
  var password = document.getElementById("password").value;
  if (password == "User" || password == "Admin")
  {
	chkAccess();
	
  }
  else
  {
    location.replace('authentication_Failure_Page.html'); //authentication failure page
  }
}

function chkAccess()
{
  //if I got here then both the userName and password are valid
   location.replace('authentication_Success_Page.html'); //authentication success page
}